package ifwhilefor;

import java.util.Scanner;

public class Factorial_combination {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("本程序计算1!+2!+......+n!的值");
        System.out.println("请输入一个整数作为n");
        int factorial_num = sc.nextInt();
        double sum = 0.0, count;
        for (int num = 1; num <= factorial_num; ++num) {
            count = 1.0;
            for (int num1 = 1; num1 <= num; ++num1) {
                count *= num1;
            }
            sum += count;
        }
        System.out.println("1!+2！+3！+4!+5!的值为：" + sum);
    }
}
